from piece import PlayerPiece

class Team:
    """ Represents a group of players """
    
    (UP, DOWN) = range(100,102)
    
    def __init__(self, orientation=None, name=None):
        self.orientation = orientation
        self.name = name
        self.players = []
        self.score = 0
        
    def add_player(self, player):
        self.players.append(player)
        player.team = self
        
    def get_keeper(self):
        for player in self.players:
            if player.id == PlayerPiece.G:
                return player
            
    def get_player(self, id):
        for player in self.players:
            if player.id == id:
                return player  
        
    def __len__(self):
        return len(self.players)
    
    def __eq__(self, team):
        return self.orientation == team.orientation
    
    def __ne__(self, team):
        return self.__eq__(self, team)
    
    